

package com.hazelcast.internal.serialization.impl.defaultserializers;

import com.hazelcast.internal.serialization.impl.SerializationConstants;
import com.hazelcast.nio.ObjectDataInput;

import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * The {@link LinkedBlockingQueue} serializer
 */
public class LinkedBlockingQueueStreamSerializer<E> extends AbstractCollectionStreamSerializer<LinkedBlockingQueue<E>> {

    @Override
    public int getTypeId() {
        return SerializationConstants.JAVA_DEFAULT_TYPE_LINKED_BLOCKING_QUEUE;
    }

    @Override
    public LinkedBlockingQueue<E> read(ObjectDataInput in) throws IOException {
        int size = in.readInt();

        LinkedBlockingQueue<E> collection = new LinkedBlockingQueue<>(size);

        return deserializeEntries(in, size, collection);
    }
}
